<template>
	<view>
		<view class="recommend f-column">
			<view class="list f-column" v-for="(item,index) in list" :key="index" @click="goDetails(item.id)">
				<!-- <view class="list_item" :style="{background:item.status==1?'#2CB9A4':'#fff'}"> -->
				<view class="list_item" :style="{background:'#fff'}">
					<view class="content">
						<view class="item" @click="goCard(item)">
							<view class="icon">
								<image :src="item.logo" mode="" class="image"></image>
							</view>
							<view class="entityList">
								<view class="num name" style="font-size: 32rpx;">
									<text>{{item.name}}</text>
									<view class="right">
										<image src="../../static/icon/my/goIcon.png" mode="" class="image"></image>
										<text class="themeColor">{{item.distance}}km</text>
									</view>
								</view>
								<view class="name">
									<text>{{item.address}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		todaySell
	} from '@/request/api.js'
	export default {
		data() {
			return {
				form: {
					lon: '',
					lat: '',
				},
				list: [],
			};
		},
		onLoad() {
			this.getAuthorizeInfo()
		},
		methods:{
			getAuthorizeInfo() {
				let self = this
				console.log(111)
				uni.authorize({
					scope: 'scope.userLocation',
					success() { // 允许授权
						uni.getLocation({
							success: function(res) {
								console.log("经纬度", res);
								self.form.lon = res.longitude
								self.form.lat = res.latitude
								self.getTodaySell()
							},
						})
					},
					fail() { // 拒绝授权
						// this.openConfirm();
						// self.$refs.uToast.show({
						// 	type: 'error',
						// 	title: '您必须允许所在位置才能使用供应大厅功能',
						// 	message: "您必须允许所在位置才能使用供应大厅功能",
						// })
						self.openAuthSetting()
						console.log("你拒绝了授权，无法获得周边信息")
					}
				})
			},
			async getTodaySell() {
				let res = await todaySell(this.form);
				this.list = res.data
			},
		}
	}
</script>

<style lang="scss" scoped>
	.recommend {
		padding: 0 20rpx;
		// margin-top: 40rpx;

		.title {
			font-size: 30rpx;
			line-height: 20px;
			color: #222222;
			font-weight: 600;
		}

		.list {
			margin-top: 20rpx;

			.content {
				// background-color: #fff;
				// box-shadow: 0px 0px 10px rgba(8, 23, 56, 0.05);
				// border-radius: 10px;
				// padding: 20rpx;
				// margin-top: 20rpx;

				.conBot {
					align-items: flex-end;

					.f-row {
						display: flex;
						align-items: flex-end;
					}

					.goNear {
						background: #2CB9A4;
						color: #fff;
						height: 60rpx;
						justify-content: center;
						align-items: center;
						border-radius: 10rpx;
						padding: 10rpx 20rpx;
						font-size: 32rpx;
						align-items: center;
					}

					display: flex;
					justify-content: space-between;
					color: #2CB9A4;

					.down {
						background: #C0EAE4;
						justify-content: center;
						display: flex;
						flex-direction: column;
						align-items: center;
						padding: 10rpx;
						font-size: 22rpx;
						border-radius: 10rpx;
						margin-right: 10rpx;
					}

					.down_price {
						margin-right: 10rpx;
					}

					.price {
						margin-right: 10rpx;
					}
				}
			}

			.list_item {
				display: flex;
				flex-direction: column;
				background: #2CB9A4;
				border-radius: 20rpx;
				padding: 0 20rpx;

				.title {
					color: #fff;
					font-size: 30rpx;
					font-weight: 600;
				}

				.item {
					display: flex;
					color: #505050;
					margin: 15rpx 0;
					border-bottom: 0.5px solid rgba(217, 217, 217, 0.3);
					padding-bottom: 15rpx;
					box-sizing: border-box;
					background: #fff;
					border-radius: 20rpx;

					.icon {
						width: 72rpx;
						height: 72rpx;
						width: 100rpx;
						height: 100rpx;

						.image {
							width: 100%;
							height: 100%;
						}
					}

					.entityList {
						flex: 1;
						display: flex;
						flex-direction: column;
						overflow: hidden;
						text-overflow: ellipsis;
						justify-content: space-between;

						.name {
							display: flex;
							justify-content: space-between;
							margin-left: 15rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							color: #BABABA;
							font-size: 28rpx;

							.image {
								width: 26rpx;
								height: 26rpx;
								margin-right: 10rpx;
							}
						}

						.num {
							margin-left: 15rpx;
							margin-top: 5rpx;
							color: #2CB9A4;
							font-size: 28rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
						}
					}
				}
			}
		}
	}

</style>
